From 9331049186ca56a1f7c03f07a2c3477674181a4c Mon Sep 17 00:00:00 2001 From: "kfraser@localhost.localdomain" Date: Wed, 13 Dec 2006 11:07:47 +0000 Subject: [PATCH] [XEND] Fix maxmem config issues. Signed-off-by: Daniel P. Berrange --- tools/python/xen/xend/XendDomainInfo.py | 8 ++++++-- tools/python/xen/xend/image.py | 13 ++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index c0a66aaf67..6a40911e04 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -896,6 +896,10 @@ class XendDomainInfo: """Get this domain's target memory size, in KB.""" return self.info['memory_static_min'] * 1024 + def getMemoryMaximum(self): + """Get this domain's maximum memory size, in KB.""" + return self.info['memory_static_max'] * 1024 + def getResume(self): return str(self._resume) @@ -1363,9 +1367,9 @@ class XendDomainInfo: # Use architecture- and image-specific calculations to determine # the various headrooms necessary, given the raw configured # values. maxmem, memory, and shadow are all in KiB. - maxmem = self.image.getRequiredAvailableMemory( - self.info['memory_static_min'] * 1024) memory = self.image.getRequiredAvailableMemory( + self.info['memory_static_min'] * 1024) + maxmem = self.image.getRequiredAvailableMemory( self.info['memory_static_max'] * 1024) shadow = self.image.getRequiredShadowMemory( self.info['shadow_memory'] * 1024, diff --git a/tools/python/xen/xend/image.py b/tools/python/xen/xend/image.py index 91a4a36f4f..59353021c0 100644 --- a/tools/python/xen/xend/image.py +++ b/tools/python/xen/xend/image.py @@ -145,6 +145,14 @@ class ImageHandler: add headroom where necessary.""" return self.getRequiredAvailableMemory(self.vm.getMemoryTarget()) + def getRequiredMaximumReservation(self): + """@param mem_kb The maximum possible memory, in KiB. + @return The corresponding required amount of memory to be free, also + in KiB. This is normally the same as getRequiredAvailableMemory, but + architecture- or image-specific code may override this to + add headroom where necessary.""" + return self.getRequiredAvailableMemory(self.vm.getMemoryMaximum()) + def getRequiredShadowMemory(self, shadow_mem_kb, maxmem_kb): """@param shadow_mem_kb The configured shadow memory, in KiB. @param maxmem_kb The configured maxmem, in KiB. @@ -593,6 +601,9 @@ class X86_HVM_ImageHandler(HVMImageHandler): def getRequiredInitialReservation(self): return self.vm.getMemoryTarget() + def getRequiredMaximumReservation(self): + return self.vm.getMemoryMaximum() + def getRequiredShadowMemory(self, shadow_mem_kb, maxmem_kb): # 256 pages (1MB) per vcpu, # plus 1 page per MiB of RAM for the P2M map, @@ -607,7 +618,7 @@ class X86_Linux_ImageHandler(LinuxImageHandler): def buildDomain(self): # set physical mapping limit # add an 8MB slack to balance backend allocations. - mem_kb = self.getRequiredInitialReservation() + (8 * 1024) + mem_kb = self.getRequiredMaximumReservation() + (8 * 1024) xc.domain_set_memmap_limit(self.vm.getDomid(), mem_kb) return LinuxImageHandler.buildDomain(self) -- 2.30.2